package com.jiutong.meipengdai.http.present;

import android.content.Context;

import com.jiutong.meipengdai.entity.BaseRespond;
import com.jiutong.meipengdai.http.model.interfaces.CheckPhoneNumBiz;
import com.jiutong.meipengdai.http.model.requests.CheckPhoneNumRequest;
import com.jiutong.meipengdai.http.subscribers.ProgressSubscriber;
import com.jiutong.meipengdai.http.subscribers.SubscriberOnNextListener;

import java.util.HashMap;

/**
 * 作用:
 * Created by 78 on 2017/6/29.
 */

public class CheckPhoneNumPresent {

    private CheckPhoneNumBiz biz;
    private Context context;
    private CheckPhoneNumRequest request;

    public CheckPhoneNumPresent(Context context, CheckPhoneNumBiz biz) {
        this.context = context;
        this.biz = biz;
    }


    public void checkVersion() {

        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<BaseRespond>() {
            @Override
            public void onNext(BaseRespond subjects) {
                biz.onSuccess(subjects);
            }

            @Override
            public void onError(Throwable e) {
                biz.onError(e);
            }
        };

        HashMap<String, Object> fieldsMap = new HashMap<>();
        fieldsMap.put("phoneNo", biz.getPhoneNum());
        request.checkPhoneNum(new ProgressSubscriber(onNextListener, context), fieldsMap);
    }
}
